package cn.iocoder.yudao.module.exam.dal.mysql.paper;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.exam.dal.dataobject.paper.PaperDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.exam.controller.admin.paper.vo.*;

/**
 * 试卷 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface PaperMapper extends BaseMapperX<PaperDO> {

    default PageResult<PaperDO> selectPage(PaperPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PaperDO>()
                .likeIfPresent(PaperDO::getPaperName, reqVO.getPaperName())
                .eqIfPresent(PaperDO::getDuration, reqVO.getDuration())
                .betweenIfPresent(PaperDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(PaperDO::getVersion, reqVO.getVersion())
                .eqIfPresent(PaperDO::getPaperType, reqVO.getPaperType())
                .eqIfPresent(PaperDO::getSingleChoiceNum, reqVO.getSingleChoiceNum())
                .eqIfPresent(PaperDO::getMultipleChoiceNum, reqVO.getMultipleChoiceNum())
                .eqIfPresent(PaperDO::getTrueFalseNum, reqVO.getTrueFalseNum())
                .eqIfPresent(PaperDO::getShortAnswerNum, reqVO.getShortAnswerNum())
                .eqIfPresent(PaperDO::getEssayNum, reqVO.getEssayNum())
                .eqIfPresent(PaperDO::getSingleChoiceScore, reqVO.getSingleChoiceScore())
                .eqIfPresent(PaperDO::getMultipleChoicePartialScore, reqVO.getMultipleChoicePartialScore())
                .eqIfPresent(PaperDO::getMultipleChoiceFullScore, reqVO.getMultipleChoiceFullScore())
                .eqIfPresent(PaperDO::getTrueFalseScore, reqVO.getTrueFalseScore())
                .eqIfPresent(PaperDO::getEasyNum, reqVO.getEasyNum())
                .eqIfPresent(PaperDO::getMediumNum, reqVO.getMediumNum())
                .eqIfPresent(PaperDO::getDifficultNum, reqVO.getDifficultNum())
                .eqIfPresent(PaperDO::getTotalScore, reqVO.getTotalScore())
                .eqIfPresent(PaperDO::getPassingScore, reqVO.getPassingScore())
                .orderByDesc(PaperDO::getId));
    }

}